package com.woniuxy.oa.service.impl;

import com.woniuxy.oa.dao.EmployeeDAO;
import com.woniuxy.oa.dao.SalaryDAO;
import com.woniuxy.oa.entity.Employee;
import com.woniuxy.oa.entity.Salary;
import com.woniuxy.oa.entity.query.EmployeeQuery;
import com.woniuxy.oa.service.EmployeeService;
import com.woniuxy.oa.util.OaUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

/**
 * The type Employee service.
 *
 * @author 毓
 */
@Service("employeeService")
public class EmployeeServiceImpl implements EmployeeService {
    /**
     * The Employee dao.用户增加实现
     */
    @Autowired
    private EmployeeDAO employeeDAO;
    @Autowired
    private SalaryDAO salaryDAO;

    @Override

    public void add(Employee employee) {
        employee.setId(OaUtil.getId());
        employee.setEmpNo("123456");
        employee.setStatus("1");
        employeeDAO.add(employee);
        Salary salary = new Salary();
        salary.setEmployee(employee);
        salary.setId(OaUtil.getId());
        salary.setBasePay(employee.getBasePay());
        salaryDAO.add(salary);
    }

    @Override
    public void update(Employee employee) {
        employeeDAO.update(employee);
    }

    @Override
    public List<Employee> query(EmployeeQuery user) {
        return employeeDAO.getUserListByUserQuery(user);
    }

    @Override
    public Employee getById(String id) {
        return employeeDAO.getById(id);
    }

    @Override
    public void lock(String id) {
        employeeDAO.lock(id);
    }

    @Override
    public void use(String id) {
        employeeDAO.use(id);
    }
}
